#ifndef MEDIAENGINE_H
#define MEDIAENGINE_H

#include <QMediaPlayer>

#include "IF_MediaEngineInterface.h"
#include "AbstractMediaSource.h"
#include "FullScreenVideoWidget.h"



class InternalEngine;
class MediaListModel;

/** this class will aggregate specific objects for plugin used
 *  in implementation. As it is not easily testable, implementation
 *  should be simple and with as few logic as possible.
 */
class MediaEngine : public IF_MediaEngineInterface
{
   Q_OBJECT
public:
   explicit MediaEngine( QObject *parent = 0);
   virtual ~MediaEngine();

public slots:
   virtual void setCurrentSource( const AbstractMediaSource *source );
   virtual void play();
   virtual void pause();
   virtual void togglePlayPause();
   virtual void stop();
   virtual void rewind();
   virtual void setVolume(int vol);
   virtual int volume();
   virtual void setTickInterval( qint32 tickMs );
   virtual AudioObject::State  state();
   virtual void onUserPositionRequested( qint64 positionMs);
   virtual void setMuted(bool isMuted);

private:
   /**
    * if not 0, player must be set to this position as
    * soon as playback starts
    */
   qint64 m_playbackStartPosition;

   /* Instantiation of this collaborator(s) makes this class untesatable.
    * However this class is mostly a wrappers QtMultimedia plugins implementation,
    * (also for video widget).
    */
   QMediaPlayer m_player;
   FullScreenVideoWidget m_videoWidget;

   // constants
private:
   /** special value for \a m_playbackStartPosition that means
    * that playback position must not be changed on next 'play' */
   static const qint64 NO_CHANGE_PLAYBACK = -1;

private slots:
   void onStateChanged(QMediaPlayer::State newState);
   void onMediaStatusChanged(QMediaPlayer::MediaStatus newStatus);
   void onVolumeChanged(int localVolume);
};


#endif // MEDIAENGINE_H
